﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using AVAilableRooms.Services;

namespace AVAilableRooms.Pages
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            // Set the data context of the listbox control to the sample data
            
            this.Loaded += new RoutedEventHandler(MainPage_Loaded);
        }

        // Load data for the ViewModel Items
        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            //ExchangeService esb = new ExchangeService("https://exchange.kandyba.nl/EWS/Exchange.asmx", new NetworkCredential("DJONKERS", "", "kandyba"));

            esb._ExchangeService.GetRoomListsCompleted += new EventHandler<Exchange.GetRoomListsCompletedEventArgs>(_ExchangeService_GetRoomListsCompleted);
            esb._ExchangeService.GetRoomListsAsync(new Exchange.GetRoomListsType());
        }

        void _ExchangeService_GetRoomListsCompleted(object sender, Exchange.GetRoomListsCompletedEventArgs e)
        {
            SecondListBox.ItemsSource = e.Result.RoomLists;
        }

        private void About_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(AboutPage.PageUrl);
        }

        private void Settings_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(SettingPage.PageUrl);
        }

        private void Reserve_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(ReservePage.PageUrl);
        }

    }
}